package com.biz.primus.ms.promotion.service.promotion;

import com.biz.primus.base.enums.PromotionTypeEnum;
import com.biz.primus.base.exception.utils.AssertUtils;
import com.biz.primus.base.redis.bean.BaseRedisObject;
import com.biz.primus.base.vo.PriceVo;
import com.biz.primus.base.vo.ProductPromotionTagRespVo;
import com.biz.primus.base.vo.ProductSpecialOfferPromotionRespVo;
import com.biz.primus.base.vo.PromotionBasicInfoVo;
import com.biz.primus.base.vo.commodity.ProductBaseVo;
import com.biz.primus.base.vo.member.MemberInfoVo;
import com.biz.primus.common.utils.SpringContextUtils;
import com.biz.primus.common.utils.ValueUtils;
import com.biz.primus.model.promotion.enums.PromotionGiftTypeEnum;
import com.biz.primus.model.promotion.enums.PromotionStatusEnum;
import com.biz.primus.model.promotion.exception.PromotionExceptionType;
import com.biz.primus.model.promotion.exception.PromotionGainLimitCountDownTimesException;
import com.biz.primus.model.promotion.vo.*;
import com.biz.primus.model.promotion.vo.req.*;
import com.biz.primus.model.promotion.vo.resp.*;
import com.biz.primus.ms.promotion.dao.po.LuckyOrderPromotion;
import com.biz.primus.ms.promotion.dao.po.PurchaseGiftPromotion;
import com.biz.primus.ms.promotion.dao.po.SignaturePromotion;
import com.biz.primus.ms.promotion.dao.po.SpecialOfferPromotionProduct;
import com.biz.primus.ms.promotion.dao.redis.*;
import com.biz.primus.ms.promotion.dao.repository.LuckyOrderPromotionRepository;
import com.biz.primus.ms.promotion.dao.repository.PurchaseGiftPromotionRepository;
import com.biz.primus.ms.promotion.dao.repository.SignaturePromotionRepository;
import com.biz.primus.ms.promotion.dao.repository.SpecialOfferPromotionRepository;
import com.biz.primus.ms.promotion.dao.ro.PresellProductRo;
import com.biz.primus.ms.promotion.dao.ro.PresellPromotionRo;
import com.biz.primus.ms.promotion.dao.ro.SeckillProductRo;
import com.biz.primus.ms.promotion.dao.ro.SeckillPromotionRo;
import com.biz.primus.ms.promotion.service.feign.MemberFeignService;
import com.biz.primus.ms.promotion.service.feign.ProductFeignService;
import com.biz.primus.ms.promotion.service.promotion.cache.PromotionCacheService;
import com.biz.primus.product.vo.SecProductInfoRespVo;
import com.google.common.collect.Lists;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 促销Service实现类
 *
 * @author david-liu
 */
@Service
public class PromotionServiceImpl extends AbstractPromotionService {

    @Autowired
    private PromotionCacheService promotionCacheService;

    @Autowired
    private MemberFeignService memberFeignService;

    @Autowired
    private SeckillPromotionRedisDao seckillPromotionRedisDao;

    @Autowired
    private PromotionGainLimitRedisDao promotionGainLimitRedisDao;

    @Autowired
    private SeckillProductRedisDao seckillProductRedisDao;

    @Autowired
    private ProductFeignService productFeignService;

    @Autowired
    private PresellPromotionRedisDao presellPromotionRedisDao;

    @Autowired
    private PresellProductRedisDao presellProductRedisDao;

    @Autowired
    private SpecialOfferPromotionRepository specialOfferPromotionRepository;

    @Override
    public OrderPromotionRespVo getPromotion4Order(OrderPromotionReqVo reqVo) {
        AssertUtils.notNull(Objects.nonNull(reqVo) && CollectionUtils.isNotEmpty(reqVo.getItems()), PromotionExceptionType.ILLEGAL_PARAMETER);
        return promotionCacheService.getAvailablePromotion4OrderInCache(reqVo);
    }

    @Override
    public ProductSpecialOfferPromotionRespVo getProductSpecialOfferPromotion(SingleProductSpecialOfferPriceReqVo reqVo) {
        AssertUtils.notNull(reqVo, PromotionExceptionType.ILLEGAL_PARAMETER);
        SpecialOfferPromotionProduct promotionInCache = promotionCacheService.getAvailableSpecialOfferPromotionInCache(reqVo);
        return Objects.isNull(promotionInCache) ? null : new ProductSpecialOfferPromotionRespVo(promotionInCache.getSpecialOfferPrice(), promotionInCache.getPurchaseQuantityLimit());
    }

    @Override
    public List<ProductSpecialOfferPromotionRespVo> getProductSpecialOfferPromotion(MultiProductSpecialOfferPriceReqVo reqVo) {
        AssertUtils.notNull(reqVo, PromotionExceptionType.ILLEGAL_PARAMETER);
        List<SpecialOfferPromotionProduct> promotionInCache = promotionCacheService.getAvailableSpecialOfferPromotionInCache(reqVo);
        if (CollectionUtils.isEmpty(promotionInCache)) {
            return Collections.emptyList();
        } else {
            List<ProductSpecialOfferPromotionRespVo> ret = Lists.newArrayList();
            List<Long> requestProductIds = reqVo.getProductIds();
            for (SpecialOfferPromotionProduct promotionProduct : promotionInCache) {
                if (requestProductIds.contains(promotionProduct.getProductId())) {
                    ret.add(new ProductSpecialOfferPromotionRespVo(promotionProduct.getSpecialOfferPrice(), promotionProduct.getPurchaseQuantityLimit()));
                } else {
                    ret.add(null);
                }
            }
            return ret;
        }
    }

    @Override
    public List<ProductPromotionTagRespVo> getProductPromotionTags(ProductPromotionTagReqVo reqVo) {
        AssertUtils.notNull(reqVo, PromotionExceptionType.ILLEGAL_PARAMETER);
        return promotionCacheService.getProductPromotionTags(reqVo);
    }

    @Override
    public PromotionBasicInfoVo getMemberMatchedSignaturePromotion(com.biz.primus.model.promotion.vo.req.SignaturePromotionReqVo reqVo) {
        AssertUtils.notNull(reqVo, PromotionExceptionType.ILLEGAL_PARAMETER);
        return promotionCacheService.getMemberMatchedSignaturePromotionInCache(reqVo.getMemberId(), reqVo.getSignatureType());
    }

    @Override
    public List<PromotionBasicInfoVo> getOrderMatchedLuckyOrderPromotion(OrderPromotionReqVo reqVo) {
        AssertUtils.notNull(reqVo, PromotionExceptionType.ILLEGAL_PARAMETER);
        return promotionCacheService.getOrderMatchedLuckyOrderPromotionInCache(reqVo);
    }

    @Override
    public Boolean takeMemberPromotions(TakeMemberPromotionReqVo reqVo) {
        return null;
    }

    @Override
    public Boolean takeMemberSignaturePromotion(TakeMemberSignaturePromotionReqVo reqVo) {
        AssertUtils.notNull(reqVo, PromotionExceptionType.ILLEGAL_PARAMETER);
        SignaturePromotionRepository signaturePromotionRepository = SpringContextUtils.getBean(SignaturePromotionRepository.class);
        AssertUtils.notNull(signaturePromotionRepository, PromotionExceptionType.ILLEGAL_STATE);
        SignaturePromotion signaturePromotion = signaturePromotionRepository.getOne(reqVo.getPromotionId());
        AssertUtils.notNull(signaturePromotion, PromotionExceptionType.ILLEGAL_STATE);
        boolean matchPromotionRule = signaturePromotion.isMatchPromotionRule(reqVo);
        if (matchPromotionRule) {
            SignatureGiftRuleVo giftRuleVo = signaturePromotion.getSignatureGiftRuleVo();
            // TODO 对接用户积分模块和优惠券模块
            return true;
        } else {
            return false;
        }
    }

    @Override
    public List<PromotionBasicInfoVo> getProductPromotions(ProductPromotionReqVo reqVo) {
        AssertUtils.notNull(reqVo, PromotionExceptionType.ILLEGAL_STATE);
        return promotionCacheService.getProductPromotions(reqVo);
    }

    @Override
    public List<SeckillPromotionRespVo> getSeckillPromotion(SeckillPromotionReqVo reqVo) {
        AssertUtils.notNull(reqVo, PromotionExceptionType.ILLEGAL_STATE);
        List<SeckillPromotionRo> seckillPromotions = seckillPromotionRedisDao.getTodayAvailableSeckillPromotions();
        if (CollectionUtils.isEmpty(seckillPromotions)) {
            return Collections.emptyList();
        }
        Long memberId = reqVo.getMemberId();
        MemberInfoVo memberInfo = memberFeignService.getMemberInfo(memberId);
        List<SeckillPromotionRo> memberWithInScopePromotions =
                seckillPromotions.stream()
                        .filter(seckillPromotionRo -> Objects.nonNull(seckillPromotionRo) && seckillPromotionRo.isMemberInPromotionScope(memberInfo))
                        .collect(Collectors.toList());
        if (CollectionUtils.isEmpty(memberWithInScopePromotions)) {
            return Collections.emptyList();
        }
        List<Long> memberWithInScopePromotionIds = Collections.emptyList();
        for (SeckillPromotionRo memberWithInScopePromotion : memberWithInScopePromotions) {
            memberWithInScopePromotionIds.add(memberWithInScopePromotion.getId());
        }
        List<Long> memberHasNotGainedPromotionIds = Objects.nonNull(memberId) ? promotionGainLimitRedisDao.filterMemberHasGainedPromotion(memberId, memberWithInScopePromotionIds) : memberWithInScopePromotionIds;
        List<SeckillPromotionRespVo> ret = Lists.newArrayList();
        Map<Long, List<Long>> promotionProducts = seckillPromotionRedisDao.getPromotionProducts(memberWithInScopePromotionIds);
        Map<Long, List<SeckillProductVo>> seckillPromotionProducts = productFeignService.getSeckillPromotionProducts(promotionProducts);
        for (SeckillPromotionRo memberWithInScopePromotion : memberWithInScopePromotions) {
            PromotionStatusEnum promotionStatus = memberWithInScopePromotion.getPromotionStatus(!memberHasNotGainedPromotionIds.contains(memberWithInScopePromotion.getId()));
            SeckillPromotionRespVo respVo = new SeckillPromotionRespVo();
            respVo.setId(memberWithInScopePromotion.getId());
            respVo.setName(memberWithInScopePromotion.getName());
            respVo.setDescription(memberWithInScopePromotion.getDescription());
            respVo.setPromotionType(PromotionTypeEnum.SECKILL);
            respVo.setPromotionDate(DateTimeFormatter.ofPattern("yyyy-MM-dd").format(memberWithInScopePromotion.getPromotionDate()));
            respVo.setStartTimePoint(DateTimeFormatter.ofPattern("HH:mm").format(memberWithInScopePromotion.getStartTimePoint()));
            respVo.setEndTimePoint(DateTimeFormatter.ofPattern("HH:mm").format(memberWithInScopePromotion.getEndTimePoint()));
            respVo.setStatus(promotionStatus);
            respVo.setSeckillProducts(seckillPromotionProducts.get(memberWithInScopePromotion.getId()));
            ret.add(respVo);
        }
        return ret;
    }

    @Override
    public SeckillProductRespVo getSeckillProduct(SeckillProductReqVo reqVo) {
        AssertUtils.isTrue(Objects.nonNull(reqVo) && Objects.nonNull(reqVo.getProductId()) && Objects.nonNull(reqVo.getPromotionId()), PromotionExceptionType.ILLEGAL_PARAMETER);
        SeckillPromotionRo seckillPromotionRo = seckillPromotionRedisDao.findOne(reqVo.getPromotionId());
        MemberInfoVo memberInfo = memberFeignService.getMemberInfo(reqVo.getMemberId());
        AssertUtils.notNull(Objects.nonNull(seckillPromotionRo) && seckillPromotionRo.isMemberInPromotionScope(memberInfo), PromotionExceptionType.ILLEGAL_STATE);
        SeckillProductRo seckillProductRo = seckillProductRedisDao.getSeckillProductRo(reqVo.getPromotionId(), reqVo.getProductId());
        AssertUtils.notNull(seckillProductRo, PromotionExceptionType.ILLEGAL_STATE);
        SecProductInfoRespVo secProductInfoRespVo = productFeignService.secProductInfo(reqVo.getProductId());
        AssertUtils.notNull(secProductInfoRespVo, PromotionExceptionType.SECKILL_PRODUCT_NOT_EXIST);
        SeckillProductRespVo respVo = new SeckillProductRespVo();
        ProductBaseVo productInfoVo = secProductInfoRespVo.getProductBaseVo();
        PriceVo priceVo = secProductInfoRespVo.getPriceVo();
        respVo.setProductId(productInfoVo.getProductId());
        respVo.setStatus(seckillPromotionRo.getPromotionStatus(promotionGainLimitRedisDao.hasMemberGainedPromotion(reqVo.getMemberId(), reqVo.getPromotionId())));
        respVo.setProductName(productInfoVo.getName());
        DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm");
        respVo.setStartTimePoint(timeFormatter.format(seckillPromotionRo.getStartTimePoint()));
        respVo.setEndTimePoint(timeFormatter.format(seckillPromotionRo.getEndTimePoint()));
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy年M月d日");
        respVo.setPromotionDate(dateTimeFormatter.format(seckillPromotionRo.getPromotionDate()));
        respVo.setMemberPrice(priceVo.getFinalPrice());
        respVo.setSeckillPrice(seckillProductRo.getSeckillPrice());
        respVo.setLogo(productInfoVo.getLogo());
        respVo.setImages(Arrays.asList(StringUtils.split(productInfoVo.getImages(), ",")));
        respVo.setIntroImages(Arrays.asList(StringUtils.split(productInfoVo.getIntroImages(), ",")));
        respVo.setLimitPurchaseQuantity(seckillProductRo.getPurchaseLimit());
        respVo.setStock(seckillProductRo.getSeckillQuantity());
        return respVo;
    }

    @Override
    public Boolean changeSeckillProductStock(ChangeSeckillProductStockReqVo reqVo) {
        AssertUtils.isTrue(Objects.nonNull(reqVo) && Objects.nonNull(reqVo.getProductId()) && Objects.nonNull(reqVo.getPromotionId()), PromotionExceptionType.ILLEGAL_PARAMETER);
        AssertUtils.isTrue(ValueUtils.getValue(reqVo.getChangeQuantity()) != 0, PromotionExceptionType.SECKILL_ORDER_CUT_QUANTITY_MUST_NOT_EQ_ZERO);
        SeckillPromotionRo seckillPromotionRo = seckillPromotionRedisDao.findOne(reqVo.getPromotionId());
        MemberInfoVo memberInfo = memberFeignService.getMemberInfo(reqVo.getMemberId());
        AssertUtils.notNull(Objects.nonNull(seckillPromotionRo) && seckillPromotionRo.isMemberInPromotionScope(memberInfo), PromotionExceptionType.ILLEGAL_STATE);
        return seckillProductRedisDao.changeSeckillProductStock(reqVo.getPromotionId(), reqVo.getProductId(), reqVo.getChangeQuantity());
    }

    @Override
    public Boolean changePresellProductStock(ChangePresellProductStockReqVo reqVo) {
        AssertUtils.isTrue(Objects.nonNull(reqVo) && Objects.nonNull(reqVo.getProductId()) && Objects.nonNull(reqVo.getPromotionId()), PromotionExceptionType.ILLEGAL_PARAMETER);
        AssertUtils.isTrue(ValueUtils.getValue(reqVo.getChangeQuantity()) != 0, PromotionExceptionType.SECKILL_ORDER_CUT_QUANTITY_MUST_NOT_EQ_ZERO);
        PresellPromotionRo presellPromotionRo = presellPromotionRedisDao.findOne(reqVo.getPromotionId());
        MemberInfoVo memberInfo = memberFeignService.getMemberInfo(reqVo.getMemberId());
        AssertUtils.notNull(Objects.nonNull(presellPromotionRo) && presellPromotionRo.isMemberInPromotionScope(memberInfo), PromotionExceptionType.ILLEGAL_STATE);
        return presellProductRedisDao.changePresellProductStock(reqVo.getPromotionId(), reqVo.getProductId(), reqVo.getChangeQuantity());
    }

    @Override
    public List<PresellPromotionRespVo> getPresellPromotion(PresellPromotionReqVo reqVo) {
        AssertUtils.notNull(reqVo, PromotionExceptionType.ILLEGAL_PARAMETER);
        List<PresellPromotionRo> presellPromotionRos = presellPromotionRedisDao.getPresellPromtoions();
        if (CollectionUtils.isEmpty(presellPromotionRos)) {
            return Collections.emptyList();
        }
        Long memberId = reqVo.getMemberId();
        MemberInfoVo memberInfo = memberFeignService.getMemberInfo(memberId);
        List<PresellPromotionRo> memberMatchedPromotions = presellPromotionRos.stream().filter(p -> Objects.nonNull(p) && p.isMemberInPromotionScope(memberInfo)).collect(Collectors.toList());
        if (CollectionUtils.isEmpty(memberMatchedPromotions)) {
            return Collections.emptyList();
        }
        List<Long> memberWithInScopePromotionIds = memberMatchedPromotions.stream().map(BaseRedisObject::getId).collect(Collectors.toList());
        List<Long> memberHasNotGainedPromotionIds = Objects.nonNull(memberId) ? promotionGainLimitRedisDao.filterMemberHasGainedPromotion(memberId, memberWithInScopePromotionIds) : memberWithInScopePromotionIds;
        Map<Long, List<Long>> promotionProducts = presellPromotionRedisDao.getPromotionProducts(memberWithInScopePromotionIds);
        Map<Long, List<PresellProductVo>> presellPromotionProducts = productFeignService.getPresellPromotionProducts(promotionProducts);
        List<PresellPromotionRespVo> ret = Lists.newArrayList();
        for (PresellPromotionRo memberWithInScopePromotion : memberMatchedPromotions) {
            PromotionStatusEnum promotionStatus = memberWithInScopePromotion.getPromotionStatus(!memberHasNotGainedPromotionIds.contains(memberWithInScopePromotion.getId()));
            PresellPromotionRespVo respVo = new PresellPromotionRespVo();
            respVo.setId(memberWithInScopePromotion.getId());
            respVo.setName(memberWithInScopePromotion.getName());
            respVo.setDescription(memberWithInScopePromotion.getDescription());
            respVo.setPromotionType(PromotionTypeEnum.PRESELL);
            respVo.setStatus(promotionStatus);
            respVo.setEndTime(DateTimeFormatter.ofPattern("yyyy-MM-dd").format(memberWithInScopePromotion.getEndTime()));
            respVo.setPresellProducts(presellPromotionProducts.get(memberWithInScopePromotion.getId()));
            respVo.setDeliverTime(DateTimeFormatter.ofPattern("yyyy-MM-dd").format(memberWithInScopePromotion.getDeliverTime()));
            ret.add(respVo);
        }

        return ret;
    }

    @Override
    public PresellProductRespVo getPresellProduct(PresellProductReqVo reqVo) {
        AssertUtils.isTrue(Objects.nonNull(reqVo) && Objects.nonNull(reqVo.getProductId()) && Objects.nonNull(reqVo.getPromotionId()), PromotionExceptionType.ILLEGAL_PARAMETER);
        PresellPromotionRo presellPromotionRo = presellPromotionRedisDao.findOne(reqVo.getPromotionId());
        MemberInfoVo memberInfo = memberFeignService.getMemberInfo(reqVo.getMemberId());
        AssertUtils.notNull(Objects.nonNull(presellPromotionRo) && presellPromotionRo.isMemberInPromotionScope(memberInfo), PromotionExceptionType.ILLEGAL_STATE);
        PresellProductRo presellProductRo = presellProductRedisDao.getPresellProductRo(reqVo.getPromotionId(), reqVo.getProductId());
        AssertUtils.notNull(presellProductRo, PromotionExceptionType.ILLEGAL_STATE);
        SecProductInfoRespVo secProductInfoRespVo = productFeignService.secProductInfo(reqVo.getProductId());
        AssertUtils.notNull(secProductInfoRespVo, PromotionExceptionType.SECKILL_PRODUCT_NOT_EXIST);
        PresellProductRespVo respVo = new PresellProductRespVo();
        ProductBaseVo productInfoVo = secProductInfoRespVo.getProductBaseVo();
        PriceVo priceVo = secProductInfoRespVo.getPriceVo();
        respVo.setProductId(productInfoVo.getProductId());
        respVo.setProductName(productInfoVo.getName());
        respVo.setStock(presellProductRo.getRemainQuantity());
        respVo.setLimitPurchaseQuantity(presellProductRo.getPurchaseLimit());
        respVo.setLogo(productInfoVo.getLogo());
        respVo.setImages(Arrays.asList(StringUtils.split(productInfoVo.getImages(), ",")));
        respVo.setIntroImages(Arrays.asList(StringUtils.split(productInfoVo.getIntroImages(), ",")));
        respVo.setMemberPrice(priceVo.getFinalPrice());
        respVo.setPresellPrice(presellProductRo.getPresellPrice());
        respVo.setStatus(presellPromotionRo.getPromotionStatus(promotionGainLimitRedisDao.hasMemberGainedPromotion(reqVo.getMemberId(), reqVo.getPromotionId())));
        respVo.setDeliverTime(DateTimeFormatter.ofPattern("yyyy-M-d").format(presellPromotionRo.getDeliverTime()));
        return respVo;
    }

    private Boolean doTakeMemberLuckyOrderPromotion(Long promotionId) {
        AssertUtils.notNull(promotionId, PromotionExceptionType.ILLEGAL_STATE);
        LuckyOrderPromotionRepository luckyOrderPromotionRepository = SpringContextUtils.getBean(LuckyOrderPromotionRepository.class);
        AssertUtils.notNull(luckyOrderPromotionRepository, PromotionExceptionType.ILLEGAL_STATE);
        LuckyOrderPromotion takingLuckyOrderPromotion = luckyOrderPromotionRepository.getOne(promotionId);
        AssertUtils.notNull(takingLuckyOrderPromotion, PromotionExceptionType.ILLEGAL_STATE);
        LuckyOrderPromotionGiftVo promotionGiftVo = takingLuckyOrderPromotion.getLuckyOrderPromotionGiftVo();
        if (Objects.isNull(takingLuckyOrderPromotion.getLuckyOrderPromotionGiftVo())) {
            return false;
        }
        if (takingLuckyOrderPromotion.getGiftType() == PromotionGiftTypeEnum.MEMBER_POINT || takingLuckyOrderPromotion.getGiftType() == PromotionGiftTypeEnum.COUPON) {
            try {
                if (takingLuckyOrderPromotion.getGiftType() == PromotionGiftTypeEnum.MEMBER_POINT) {
                    // TODO 对接会员积分模块
                } else {
                    // TODO 对接优惠券模块
                }
                return promotionGainLimitRedisDao.decreasePromotionEffectTimes(takingLuckyOrderPromotion.getId(), PromotionTypeEnum.LUCKY_ORDER);
            } catch (Exception e) {
                if (e instanceof PromotionGainLimitCountDownTimesException) {
                    promotionGainLimitRedisDao.increasePromotionEffectTimes(takingLuckyOrderPromotion.getId(), PromotionTypeEnum.LUCKY_ORDER);
                }
                return false;
            }
        } else {
            return false;
        }
    }

    private Boolean doTakeMemberPurchaseGiftPromotion(Long promotionId) {
        AssertUtils.notNull(promotionId, PromotionExceptionType.ILLEGAL_STATE);
        PurchaseGiftPromotionRepository purchaseGiftPromotionRepository = SpringContextUtils.getBean(PurchaseGiftPromotionRepository.class);
        AssertUtils.notNull(purchaseGiftPromotionRepository, PromotionExceptionType.ILLEGAL_STATE);
        PurchaseGiftPromotion purchaseGiftPromotion = purchaseGiftPromotionRepository.getOne(promotionId);
        PurchaseGiftRuleVo purchaseGiftRule = purchaseGiftPromotion.getPurchaseGiftRule();
        if (Objects.isNull(purchaseGiftRule)) {
            return false;
        }
        if (purchaseGiftPromotion.getGiftType() == PromotionGiftTypeEnum.MEMBER_POINT || purchaseGiftPromotion.getGiftType() == PromotionGiftTypeEnum.COUPON) {
            try {
                if (purchaseGiftPromotion.getGiftType() == PromotionGiftTypeEnum.MEMBER_POINT) {
                    // TODO 对接会员积分模块
                } else {
                    // TODO 对接优惠券模块
                }
                return true;
            } catch (Exception e) {
                return false;
            }
        } else {
            return false;
        }

    }
}
